VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmETD 
   BackColor       =   &H00FFFFFF&
   Caption         =   "ETD"
   ClientHeight    =   4860
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5760
   Icon            =   "frmETD.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   4860
   ScaleWidth      =   5760
   StartUpPosition =   1  'CenterOwner
   Begin MSComDlg.CommonDialog dlgEDTFilename 
      Left            =   240
      Top             =   4080
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton cmdClose 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Save/Exit"
      Height          =   315
      Left            =   3240
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   4200
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Frame frameETD 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Select Type and Filenames"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   3735
      Left            =   120
      TabIndex        =   5
      Top             =   120
      Width           =   5535
      Begin VB.CommandButton cmd2819 
         BackColor       =   &H00E0E0E0&
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   8.25
            Charset         =   0
            Weight          =   900
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Index           =   4
         Left            =   4920
         Style           =   1  'Graphical
         TabIndex        =   24
         Top             =   3000
         Width           =   375
      End
      Begin VB.TextBox f2819 
         Height          =   285
         Index           =   4
         Left            =   1560
         TabIndex        =   23
         Top             =   3000
         Width           =   3255
      End
      Begin VB.CommandButton cmd2819 
         BackColor       =   &H00E0E0E0&
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   8.25
            Charset         =   0
            Weight          =   900
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Index           =   3
         Left            =   4920
         Style           =   1  'Graphical
         TabIndex        =   21
         Top             =   2640
         Width           =   375
      End
      Begin VB.TextBox f2819 
         Height          =   285
         Index           =   3
         Left            =   1560
         TabIndex        =   20
         Top             =   2640
         Width           =   3255
      End
      Begin VB.CommandButton cmd2819 
         BackColor       =   &H00E0E0E0&
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   8.25
            Charset         =   0
            Weight          =   900
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Index           =   2
         Left            =   4920
         Style           =   1  'Graphical
         TabIndex        =   18
         Top             =   2280
         Width           =   375
      End
      Begin VB.TextBox f2819 
         Height          =   285
         Index           =   2
         Left            =   1560
         TabIndex        =   17
         Top             =   2280
         Width           =   3255
      End
      Begin VB.CommandButton cmd2819 
         BackColor       =   &H00E0E0E0&
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   8.25
            Charset         =   0
            Weight          =   900
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Index           =   1
         Left            =   4920
         Style           =   1  'Graphical
         TabIndex        =   15
         Top             =   1920
         Width           =   375
      End
      Begin VB.TextBox f2819 
         Height          =   285
         Index           =   1
         Left            =   1560
         TabIndex        =   14
         Top             =   1920
         Width           =   3255
      End
      Begin VB.TextBox f2819 
         Height          =   285
         Index           =   0
         Left            =   1560
         TabIndex        =   12
         Top             =   1560
         Width           =   3255
      End
      Begin VB.CommandButton cmd2819 
         BackColor       =   &H00E0E0E0&
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   8.25
            Charset         =   0
            Weight          =   900
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Index           =   0
         Left            =   4920
         Style           =   1  'Graphical
         TabIndex        =   11
         Top             =   1560
         Width           =   375
      End
      Begin VB.TextBox f6115 
         Height          =   285
         Left            =   1560
         TabIndex        =   9
         Top             =   1200
         Width           =   3255
      End
      Begin VB.CommandButton cmd6115 
         BackColor       =   &H00E0E0E0&
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   8.25
            Charset         =   0
            Weight          =   900
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   4920
         Style           =   1  'Graphical
         TabIndex        =   8
         Top             =   1200
         Width           =   375
      End
      Begin VB.CommandButton cmd6114 
         BackColor       =   &H00E0E0E0&
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   8.25
            Charset         =   0
            Weight          =   900
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   4920
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   840
         Width           =   375
      End
      Begin VB.TextBox f6114 
         Height          =   285
         Left            =   1560
         TabIndex        =   2
         Top             =   840
         Width           =   3255
      End
      Begin VB.OptionButton opt2821FG 
         BackColor       =   &H00FFFFFF&
         Caption         =   "FedEx Generated"
         Height          =   255
         Left            =   1680
         TabIndex        =   0
         Top             =   360
         Width           =   1575
      End
      Begin VB.OptionButton opt2821MO 
         BackColor       =   &H00FFFFFF&
         Caption         =   "My Own"
         Height          =   255
         Left            =   3720
         TabIndex        =   1
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label lbl2819 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Other 2:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   4
         Left            =   120
         TabIndex        =   25
         Top             =   3000
         Width           =   1095
      End
      Begin VB.Label lbl2819 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Other 1:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   3
         Left            =   120
         TabIndex        =   22
         Top             =   2640
         Width           =   1095
      End
      Begin VB.Label lbl2819 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Pro forma:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   2
         Left            =   120
         TabIndex        =   19
         Top             =   2280
         Width           =   1095
      End
      Begin VB.Label lbl2819 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Cert Origin:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   120
         TabIndex        =   16
         Top             =   1920
         Width           =   1095
      End
      Begin VB.Label lbl2819 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "CI:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   13
         Top             =   1560
         Width           =   1095
      End
      Begin VB.Label lbl6115 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Signature:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   1200
         Width           =   1095
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "CI Type:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   7
         Top             =   360
         Width           =   855
      End
      Begin VB.Label lbl6114 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Letterhead:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   840
         Width           =   1095
      End
   End
End
Attribute VB_Name = "frmETD"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit


Public Function ETDFolder() As String

    Dim strFolder As String
    strFolder = g_clsSettings.Setting("EDTFolder")
    If strFolder <> "" Then
        If MainFSO.FolderExists(strFolder) Then
            If Right(strFolder, 1) <> "\" Then strFolder = strFolder & "\"
            strFolder = strFolder & "*.*"
        End If
    End If
    ETDFolder = strFolder
    
End Function


Private Sub cmd2819_Click(Index As Integer)

    dlgEDTFilename.InitDir = g_clsSettings.Setting("EDTFolder")

    dlgEDTFilename.ShowOpen
    f2819(Index).Text = dlgEDTFilename.FileName

End Sub

' 2011-04-07, JFW, Added for Scapa.


'
'Private Sub cmd2819_Click()
'    dlgEDTFilename.ShowOpen
'    f2819.Text = dlgEDTFilename.FileName
'End Sub

Private Sub cmd6114_Click()
    
    dlgEDTFilename.InitDir = g_clsSettings.Setting("EDTFolder")
    
    dlgEDTFilename.ShowOpen
    f6114.Text = dlgEDTFilename.FileName
End Sub

Private Sub cmd6115_Click()
    
    dlgEDTFilename.InitDir = g_clsSettings.Setting("EDTFolder")
    
    dlgEDTFilename.ShowOpen
    f6115.Text = dlgEDTFilename.FileName
End Sub

'---------------------------------------------------------------------------------------
' Procedure : cmdClose_Click()
' DateTime  : 3/25/2004
' Purpose   : Close button clicked, hide form
'---------------------------------------------------------------------------------------
'
Private Sub cmdClose_Click()
    
    With g_clsReg
        If opt2821FG.Value Then
            .SetRegistryValue "ETD_CI_Type", "F", REG_SZ
        End If
        If opt2821MO.Value Then
            .SetRegistryValue "ETD_CI_Type", "C", REG_SZ
        End If
        .SetRegistryValue "EDT_Letterhead", f6114.Text, REG_SZ
        .SetRegistryValue "EDT_Signature", f6115.Text, REG_SZ
    End With
    
    Call AssignFormGlobalVars
    Me.Hide
    'Unload Me
    'If frmShip.Visible Then frmShip.SetFocus

End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : AssignFormGlobalVars()
' DateTime  : 4/26/2006
' Purpose   : Assign the form's global vars
'---------------------------------------------------------------------------------------
'
Public Sub AssignFormGlobalVars()
    
    Dim i As Long
    Dim inst As Long
    Dim strf1 As String
    Dim strFilename As Variant
    
    If g_clsSettings.Setting("EDTFolder") <> "" Then
        If MainFSO.FolderExists(g_clsSettings.Setting("EDTFolder")) Then
            strf1 = IIf(frmShip.f1.Visible, frmShip.f1, frmShip.cboCustID)
            If strf1 <> "" Then
                For Each strFilename In MainFSO.GetFolder(g_clsSettings.Setting("EDTFolder")).Files
                    If 0 <> InStr(1, LCase(strFilename), LCase(strf1)) Then
                        If 0 <> InStr(1, LCase(strFilename), LCase("letter")) Then
                            If f6114.Text = "" Then
                                f6114.Text = strFilename
                            End If
                        ElseIf 0 <> InStr(1, LCase(strFilename), LCase("sign")) Then
                            If f6115.Text = "" Then
                                f6115.Text = strFilename
                            End If
                        ElseIf 0 <> InStr(1, LCase(strFilename), LCase("ci")) Then
                            If f2819(0).Text = "" Then
                                f2819(0).Text = strFilename
                            End If
                        ElseIf 0 <> InStr(1, LCase(strFilename), LCase("invoice")) Then
                            If f2819(0).Text = "" Then
                                f2819(0).Text = strFilename
                            End If
                        ElseIf 0 <> InStr(1, LCase(strFilename), LCase("origin")) Then
                            If f2819(1).Text = "" Then
                                f2819(1).Text = strFilename
                            End If
                        ElseIf 0 <> InStr(1, LCase(strFilename), LCase("proforma")) Then
                            If f2819(2).Text = "" Then
                                f2819(2).Text = strFilename
                            End If
                        Else
                            If f2819(3).Text = "" Or f2819(3) = strFilename Then
                                f2819(3).Text = strFilename
                            ElseIf f2819(4).Text = "" Or f2819(4) = strFilename Then
                                f2819(4).Text = strFilename
                            End If
                        End If
                    End If
                Next strFilename
            End If
        End If
    End If
    
    g_strETD = "113,""Y""2805,""Y""2820,""N"""
    With g_clsReg
        If .GetRegistryValue("ETD_CI_Type", "") <> "" Then
            g_strETD = g_strETD & "2821,""" & .GetRegistryValue("ETD_CI_Type", "") & """"
        End If
        If True Or .GetRegistryValue("ETD_CI_Type", "") = "C" Then
            For i = 0 To 4
                If f2819(i) <> "" Then
                    inst = inst + 1
                    If i >= 4 Then
                        g_strETD = g_strETD & "2818-" & inst & ",""" & "4" & """"
                    Else
                        g_strETD = g_strETD & "2818-" & inst & ",""" & CStr(i + 1) & """"
                    End If
                    If f2819(i).Text <> "" Then
                        g_strETD = g_strETD & "2819-" & inst & ",""" & f2819(i).Text & """"
                    End If
                End If
            Next i
        End If
        If .GetRegistryValue("ETD_CI_Type", "") = "F" Then
            If .GetRegistryValue("EDT_Letterhead", "") <> "" Then
                g_strETD = g_strETD & "6112,""Y"""
                g_strETD = g_strETD & "6114,""" & .GetRegistryValue("EDT_Letterhead", "") & """"
            End If
            If .GetRegistryValue("EDT_Signature", "") <> "" Then
                g_strETD = g_strETD & "6113,""Y"""
                g_strETD = g_strETD & "6115,""" & .GetRegistryValue("EDT_Signature", "") & """"
            End If
        End If
    End With
'    Document Type                 2818-#             (1=Commercial Invoice)
'ETD Wait for Confirmation         2820                 (Y/N)
'ETD Document Generation        2821-#             (F=FedEx Generated)
'Digital Signature Indicator          6113-#              (Y/N)
'Digital Letterhead Image Path    6114-#             Value is a file path that specifies where the digital letterhead image file is located.
'Digital Signature Image Path      6115-#              Value is a file path that specifies where the digital signature image file is located.


    DebugPrint "AssignFormGlobalVars, " & g_strETD

End Sub


'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Form_Load()
' DateTime  : 3/25/2004
' Purpose   : Set Append as default import method and set Status caption to Idle.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Load()

    With g_clsReg
        If .GetRegistryValue("ETD_CI_Type", "") = "F" Then
            opt2821FG.Value = 1
        End If
        If .GetRegistryValue("ETD_CI_Type", "") = "C" Then
            opt2821MO.Value = 1
        End If
        f6114.Text = .GetRegistryValue("EDT_Letterhead", "")
        f6115.Text = .GetRegistryValue("EDT_Signature", "")
        
        Call AssignFormGlobalVars
        
    End With

End Sub

